//
//  DoctorDetailHeaderView.swift
//  EyeVisionForPatients
//
//  Created by PMC on 2020/2/26.
//  Copyright © 2020 tao Tao. All rights reserved.
//

import UIKit

class DoctorDetailHeaderView: UIView {
    
    var viewModel: DoctorDetailViewModel?
    
    @IBOutlet private weak var nameLabel: UILabel!
    
    @IBOutlet private weak var avatarView: UIImageView! {
        didSet {
            avatarView.contentMode = .scaleAspectFill
            avatarView.layer.cornerRadius = 36
            avatarView.layer.masksToBounds = true
        }
    }
    
    @IBOutlet private weak var deptLabel: UILabel!
    
    @IBOutlet private weak var hospitalLabel: UILabel!

    
    @IBOutlet private weak var scoreLabel: UILabel!
    

    
    func configure(with vm: DoctorDetailViewModel?) {
        guard let vm = vm else { return }
        avatarView.kf.setImage(with: URL(string: vm.thumbnailUrl),
                               placeholder: UIImage(named: "avatar_default"))
        self.viewModel = vm
        nameLabel.text = vm.doctorName
        deptLabel.text = vm.deptAndOffice
        hospitalLabel.text = vm.hospitalName

        scoreLabel.text = vm.score
    }
    
    func updateData(with viewModel: ESGTeamInquiryViewModel.RowViewModel?) {
        guard let vm = viewModel else { return }
        avatarView.kf.setImage(with: URL(string: vm.avatarSD),
                               placeholder: UIImage(named: "avatar_default"))
        nameLabel.text = vm.teamName
        deptLabel.text = "负责人：\(vm.teamLeaderName) \(vm.teamLeaderOffice)"
        hospitalLabel.text = vm.hospitalName
        scoreLabel.text = vm.score
    }
}
